package work.sby.mapper;
import org.apache.ibatis.annotations.*;
import work.sby.pojo.Brand;
import java.util.List;

public interface BrandMapper {

// 查询所有品牌

@Select("SELECT * FROM tb_brand")
@ResultMap("brandResultMap")
List<Brand> selectAll();

    @Insert("insert into tb_brand values(null,#{brandName},#{companyName},#{price},#{description},#{status})")
    void add(Brand brand);
    /**
     * 根据id查询
     * @param id
     * @return
     */
    @Select("select * from tb_brand where id = #{id}")
    @ResultMap("brandResultMap")
    Brand selectById(int id);

    @Select("SELECT * FROM tb_brand WHERE brand_name LIKE CONCAT('%', #{brandName}, '%')")
    @ResultMap("brandResultMap")
    List<Brand> selectByBrandName(String brandName);
    /**
     * 修改
     * @param brand
     */
    @Update("update tb_brand set brand_name = #{brandName},company_name = #{companyName},price = #{price},description = #{description},status = #{status} where id = #{id}")
    void update(Brand brand);

    @Delete("delete from tb_brand where id=#{id};")
    void deleteById(int id);
}
